<?php

	include_once('../sys/sys.php');
	include_once ('../sys/json/JSON.php');
	header('Content-Type: text/html; charset=utf-8');
	
	
	
	//获取系统内容以及分页
	
	//获取分类以及分页号
	$action = $_GET['action'];
	$st = $_GET['st'];
	$cid = $_GET['cid'];
	$jid = $_GET['jid'];
	if(is_null($st)){$st = 0;}
	//列出的图片数量(注意,不要超过15张)
	$listnum = 19;
	
	$array_piclist = array();
	$json_str = array();
	
	
	$DB->build_query(array(
			'select' 	=> 'id,name',
			'from'		=> 'gfuntags',
			'where'		=> 'depth=1',
			//'limit'		=> array($st,$listnum)
	));
	$qid = $DB->exec_query();
	$i = 0;
	while ($row = $DB->fetch_row($qid)) {
		$array_piclist[$i]['tagname'] = $row['name'];
		$json_str[$i]['name'] = $row['name'];
		$json_str[$i]['id'] = $row['id'];
		$array_piclist[$i]['id'] = $row['id'];
		$array_piclist[$i]['downloadpicslink'] = SITE_URL . 'gfun/pics.php?action=getpicfiles&tid=' .$row['id'];
		$array_piclist[$i]['picslink'] = SITE_URL . 'gfun/pics.php?action=getpicurls&tid=' .$row['id'];
		$array_piclist[$i]['logopicslink'] = SITE_URL . 'gfun/pics.php?action=getlogopicurls&tid=' .$row['id'];
		$array_piclist[$i]['getnewlink'] = SITE_URL . 'gfun/cr.php?tid=' .$row['id'];
		$array_piclist[$i]['showapplink'] = SITE_URL . 'gfun/pics.php?action=showapplinks&tid=' .$row['id'];
		$i++;
	}
	
	if ($action == 'get_json'){
		$json = new Services_JSON();
		$output = $json->encode($json_str);
		echo $output;
		exit;
	}
	
	
	//初始化模版变量
	$page = init_smart_template_obj('gfun/list.html',CACHE_DIR,CACHE_DIR,TEMPLATE_DIR);
	$page->assign("piclist",$array_piclist);
	$page->assign("system",$sysinfo);
	$page->assign("title","列表");
	$page->assign("tidlink",$array_ccount);

	$page->output();
	
?>